#include <stdio.h>

int main() {
    FILE* fp = fopen("example.txt", "r");  //打开文件
    if (fp == NULL) {
        printf("Failed to open file.\n");
        return -1;
    }

    char buffer[100];
    size_t result = fread(buffer, 1, 10, fp);  //读取文件数据
    if (result != 10) {
        if (ferror(fp)) {  // 检测错误标志
            printf("Error reading file.\n");
            clearerr(fp);  //清除错误标志
        } else if (feof(fp)) {
            printf("End of file reached.\n"); //如果到达文件结尾
        }
    }

    fclose(fp); // 关闭文件
    return 0;
}
